Report post

What is document Cookie?

What is document.cookie? I’ve used cookies as a web developer for many years, but never understood them in detail. In this post, I look at the document.cookie API. Cookies are client-side storage. Cookies were the first client-side storage available in the browser. They have three main use-cases: sessions, preferences, and tracking.

What is a cookie & how does it work?

A cookie is a small piece of data that you can store in a browser. Before the introduction of mechanisms such as WebStorage API, they were the only way to store data on the browser. Therefore, cookies used to be a legitimate solution for general client-side storage. It is a single string (up to 4KB) that combines all the data.

What data is stored in a cookie?

Data stored in a cookie is created by the server upon your connection. This data is labeled with an ID unique to you and your computer. When the cookie is exchanged between your computer and the network server, the server reads the ID and knows what information to specifically serve to you.

What are HTTP cookies?

HTTP cookies are a repurposed version of the “magic cookie” built for internet browsing. Web browser programmer Lou Montulli used the “magic cookie” as inspiration in 1994. He recreated this concept for browsers when he helped an online shopping store fix their overloaded servers.

Related articles

The World's Leading Crypto Trading Platform

Get my welcome gifts